﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="MyVendorOffers.ascx.cs" Inherits="Gollie.Controls.MyVendorOffers" %>
<%@ Register Src="ErrorMessageControl.ascx" TagName="ErrorMessageControl" TagPrefix="uc1" %>
<%@ Register TagPrefix="uc2" Namespace="Gollie.Controls.BoundFields" Assembly="Gollie" %>

<p class="title">Lopende deals</p>
<uc1:ErrorMessageControl id="ErrorMessageControl1" runat="server" Visible="false"></uc1:ErrorMessageControl>
<div style="padding: 8px; text-align: center;">
<a href="/AddOffer.aspx" class="button">Maak een nieuwe deal</a>
</div>
<div style="height: 8px;">
</div>

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" ShowHeaderWhenEmpty="True" Width="100%" CellPadding="4" ForeColor="#333333" GridLines="None" HorizontalAlign="Center" OnRowCommand="GridView1_RowCommand" OnRowDataBound="GridView1_RowDataBound"  AllowSorting="true" OnSorting="GridView1_Sorting">
     <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
    <Columns>
        <asp:TemplateField HeaderText="Bewerk">
            <ItemTemplate>
                <asp:ImageButton ID="btnEdit" runat="server"
                    ImageUrl="~/Images/edit.png"
                    ToolTip="Bewerken"
                    CommandName="EditRow" 
                    CommandArgument='<%#String.Concat(DataBinder.Eval(Container.DataItem, "OfferId"), "|", ((GridViewRow) Container).RowIndex) %>'
                    />
                <asp:ImageButton ID="btnDelete" runat="server"
                    ImageUrl="~/Images/delete.png"
                    ToolTip="Verwijderen"
                    CommandName="DeleteRow" 
                    CommandArgument='<%#String.Concat(DataBinder.Eval(Container.DataItem, "OfferId"), "|", ((GridViewRow) Container).RowIndex) %>'
                    Visible = '<%#Convert.ToInt32(DataBinder.Eval(Container.DataItem, "NumberSold"))==0%>'
                    OnClientClick="return confirm('U staat op het punt een deal te verwijderen.\r\n\r\nDoorgaan?');"
                    />
                <asp:ImageButton ID="btnWithdraw" runat="server"
                    ImageUrl="~/Images/withdraw.png"
                    ToolTip="Terugtrekken"
                    CommandName="WithdrawRow" 
                    CommandArgument='<%#String.Concat(DataBinder.Eval(Container.DataItem, "OfferId"), "|", ((GridViewRow) Container).RowIndex) %>'
                    Visible = '<%#Convert.ToInt32(DataBinder.Eval(Container.DataItem, "NumberSold"))>0 && Convert.ToDateTime(Eval("ValidTo")) > DateTime.Now%>'
                    OnClientClick="return confirm('U staat op het punt een deal terug te trekken door de vervaldatum op vandaag te zetten.\r\nDe reeds verkochte deals blijven geldig.\r\n\r\nDoorgaan?');"
                    />
            </ItemTemplate>
            <HeaderStyle CssClass="offer-grid-header" />
            <ItemStyle CssClass="offer-grid-cell-edit" />
        </asp:TemplateField>
        
        
        <asp:TemplateField HeaderText="Aangemaakt" SortExpression="EntryDate">
            <ItemTemplate>
                <asp:Label ID="Label1" runat="server" Text='<%# Bind("EntryDate", "{0:dd-MMM-yyyy}") %>' ToolTip='<%# String.Concat("Maker: ", Eval("UserFullName"), " om ", Eval("EntryDate", "{0:HH:mm}") ) %>'></asp:Label>
            </ItemTemplate>
            <HeaderStyle CssClass="offer-grid-header" />
            <ItemStyle CssClass="offer-grid-cell" />
        </asp:TemplateField>

        <asp:BoundField DataField="Credit" DataFormatString="{0:c}" HeaderText="Tegoed" SortExpression="Credit">
         <HeaderStyle CssClass="offer-grid-header" />
         <ItemStyle CssClass="offer-grid-cell" />
        </asp:BoundField>

        <asp:BoundField DataField="Price" DataFormatString="{0:c}" HeaderText="Prijs" SortExpression="Price">
         <HeaderStyle CssClass="offer-grid-header" />
         <ItemStyle CssClass="offer-grid-cell" />
        </asp:BoundField>

        <uc2:BoundFieldExpirationPeriod DataField="ExpiresAfter" HeaderText="Looptijd">
         <HeaderStyle CssClass="offer-grid-header" />
         <ItemStyle CssClass="offer-grid-cell" />
        </uc2:BoundFieldExpirationPeriod>

        <uc2:BoundFieldValidFrom DataField="ValidFrom" HeaderText="Gaat in op" SortExpression="ValidFrom">
         <HeaderStyle CssClass="offer-grid-header" />
         <ItemStyle CssClass="offer-grid-cell" />
         </uc2:BoundFieldValidFrom>

        <uc2:BoundFieldValidTo DataField="ValidTo" HeaderText="Aangeboden tot" SortExpression="ValidTo">
          <HeaderStyle CssClass="offer-grid-header" />
          <ItemStyle CssClass="offer-grid-cell" />
        </uc2:BoundFieldValidTo>

        <uc2:BoundFieldOffersMax DataField="NumberMax" HeaderText="Maximum" SortExpression="NumberMax">
         <HeaderStyle CssClass="offer-grid-header" />
         <ItemStyle CssClass="offer-grid-cell" />
        </uc2:BoundFieldOffersMax>

        <asp:BoundField DataField="NumberSold" HeaderText="Verkocht" NullDisplayText="0" SortExpression="NumberSold">
         <HeaderStyle CssClass="offer-grid-header" />
         <ItemStyle CssClass="offer-grid-cell" />
        </asp:BoundField>

    </Columns>
        <EditRowStyle BackColor="#999999" />
        <FooterStyle BackColor="#000000" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#000000" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
        <SortedAscendingCellStyle BackColor="#E9E7E2" />
        <SortedAscendingHeaderStyle BackColor="#506C8C" />
        <SortedDescendingCellStyle BackColor="#FFFDF8" />
        <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
<br />
<asp:Label ID="lblNoOffersYet" runat="server" style="font-size: 1.3em; font-weight: bold;">Nog geen deals gepubliceerd.</asp:Label>
<br />
<hr />
<br />
<span class="common">Onderstaand is de rechtstreekse link naar uw deals voor bezoekers van Gollie.nl. U kunt deze link gebruiken om uw deals via uw eigen website onder de aandacht te brengen.</span>
<br />
<div style="border: 1px solid black; background-color: white; font-family: 'Courier New'; padding: 4px; margin: 4px;">
<asp:HyperLink ID="hplConsumerLink" runat="server" CssClass="common"></asp:HyperLink>
</div>
<br />
<br />
<span class="common">Dit is een voorbeeld van een HTML-snippet die u op uw website kunt plaatsen:</span>
<br />
<div style="border: 1px solid black; background-color: white; font-family: 'Courier New'; padding: 4px; margin: 4px;">
<asp:Label ID="lblHtmlSnippet" runat="server"></asp:Label>
<br />
<br />
</div>
<div style="border: 1px solid black; background-color: white; padding: 4px; margin: 4px;">
	<asp:Label ID="lblHtmlResult" runat="server"></asp:Label>
</div>